<?php
namespace Home\Model;
use Think\Model\RelationModel;

class TeacherModel extends RelationModel{
    //关联
    protected $_link = array(
        "college"=>array(
            "mapping_type"=>2,
            "class_name"=>"college",
            "mapping_name"=>"college",
            "foreign_key"=>"college_col_id",
            "parent_key"=>"cou_id",
            "as_fields"=>"col_name"
        )
    );
    //自动验证
    protected $_validate = array(
        //注册的时候的自动验证   1
        array("tea_number","require","教师工号不能为空!",1,"regex",1),
        array("tea_password_hash","require","密码不能为空!",1,"regex",3),     //修改密码的时候也用到
        array("tea_name","require","姓名不能为空!",1,"regex",1),
        array("tea_email","email","邮箱格式有误!",1,"regex",1),
        array("college_col_id","number","学校id必须为正整数!",1,"regex",1),
        //登陆  4
        array("tea_email","email","邮箱格式有误!",1,"regex",4),
        array("tea_password_hash","require","密码不能为空!",1,"regex",4),
        //email的检测
        array("tea_email","email","邮箱格式有误!",1,"regex",2),
        //工号检测 5
        array("tea_number","require","密码不能为空!",1,"regex",5),
        array("college_col_id","number","学校id必须为正整数!",1,"regex",5),
        //更新教师基本信息6
        array("tea_name","require","教师姓名不能为空!",1,"regex",6),
        array("sex",array("男","女"),"不能出现其他性别!",1,"in",6),
    );
    //自动填充
    protected $_auto = array(
        array("sex","男",1),         //注册(新增)的时候自动填充
    );
}